import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:kkhousekeep/models/notice_list_entity.dart';
import 'package:kkhousekeep/widget/shadow_widget.dart';

class NoticeItem extends StatefulWidget {
  const NoticeItem(this._noticeModel, this.onTap, {super.key});

  final NoticeListObjList _noticeModel;
  final GestureTapCallback? onTap;

  @override
  State<StatefulWidget> createState() {
    return _NoticeItemState();
  }
}

class _NoticeItemState extends State<NoticeItem> {
  @override
  Widget build(BuildContext context) {
    Color titleColor = widget._noticeModel.read == 0
        ? const Color(0XFF333333)
        : const Color(0XFFA4A4A4);

    return GestureDetector(
      onTap: widget.onTap,
      child: ShadowWidget.fixedHeight(
        height: 128,
        backgroundColor: Colors.white,
        marginHorizontal: 32,
        marginVertical: 8,
        child: Container(
          padding:
              EdgeInsets.only(top: 26.h, bottom: 26.h, left: 24.w, right: 20.w),
          decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(16.w), color: Colors.white),
          child: Row(
            children: [
              Expanded(
                  child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    widget._noticeModel.title,
                    style: TextStyle(
                      fontSize: 32.sp,
                      color: titleColor,
                    ),
                    overflow: TextOverflow.ellipsis,
                    maxLines: 1,
                  ),
                  const Spacer(),
                  Text(widget._noticeModel.publishTime,
                      style: TextStyle(
                          fontSize: 24.sp, color: const Color(0xFF7C7E80)))
                ],
              )),
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Text('阅读',
                      style: TextStyle(
                          fontSize: 24.sp, color: const Color(0xFF7C7E80))),
                  Image(
                    fit: BoxFit.fill,
                    image: const AssetImage(
                        'assets/images/icon_segue_arrow_grey.png'),
                    width: 24.w,
                    height: 24.h,
                  )
                ],
              )
            ],
          ),
        ),
      ),
    );
  }
}
